<?php


namespace App\Services;


class Config
{
    // 袤博秒验
    const KEY_MOB_COM_APPID = 'mob_com_appid';
    const KEY_MOB_COM_SECRET = 'mob_com_secret';
    const KEY_MOB_COM_MD5 = 'mob_com_md5';
    const KEY_SMS_TPL = 'sms_tpl';
    const KEY_SMS_EXPIRE_IN_MINUTES = 'sms_expire_in_minutes';
    const KEY_SMS_SIGN_TAG = 'sms_sign_tag';
    const KEY_SMS_USER_ID = 'sms_user_id';
    const KEY_SMS_USERNAME = 'sms_username';
    const KEY_SMS_PASSWORD = 'sms_password';
    const KEY_SMS_PASS_MOBILES = "sms_pass_mobiles";

    protected static function getDefaultValues(){
        return [
            self::KEY_SMS_TPL => '您的验证码是{#code#}，{#expire#}分钟内输入有效。',
            self::KEY_SMS_EXPIRE_IN_MINUTES => 10,
            self::KEY_SMS_SIGN_TAG => '抖个球',
            self::KEY_SMS_PASS_MOBILES => [],
        ];
    }

    public static function get($key, $default=null){
        if($default===null){
            $defaults = self::getDefaultValues();
            if(isset($defaults[$key])){
                $default = $defaults[$key];
            }
        }
        $localEnvFile = base_path("env.local.php");
        if(file_exists($localEnvFile)){
            $localEnvs = require $localEnvFile;
            if(isset($localEnvs[$key])){
                return $localEnvs[$key];
            }
        }
        return env($key, $default);
    }

}
